// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App'
// import VueSocketIO from 'vue-socket.io'
// import socketIO from 'socket.io-client'
import router from './router'
import ZH from './lang/ZH'
import EN from './lang/EN'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import * as filters from './filters/index'
import 'lib-flexible'

require('./mock')
Vue.config.productionTip = false
Vue.use(VueI18n)

const messages = {
  en: {
    message: EN,
    ...enLocale // 使用element-ui框架的国际化
  },
  zh: {
    message: ZH,
    ...zhLocale
  }
}

const i18n = new VueI18n({
  locale: 'zh',
  messages
})

// Vue.use(new VueSocketIO({
//   debug: true,
//   connection: 'http://127.0.0.1:8000'
// }))

/* size用于设置组件的默认尺寸，zIndex设置弹窗的初始z-index（默认值2000） */
Vue.use(ElementUI, { size: 'small', zIndex: 3000, i18n: (key, value) => i18n.t(key, value) })

Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  i18n,
  components: { App },
  template: '<App/>'
})
